class Payment:
    """支付接口，定义了 pay 方法。"""

    def pay(self):
        raise NotImplementedError("Subclasses must implement this method")


class RealPayment(Payment):
    """实际支付类，实现支付接口。"""

    def pay(self):
        print("Paying...")


class PaymentProxy(Payment):
    """支付代理类，增加日志记录功能。"""

    def __init__(self, real_payment):
        self.real_payment = real_payment

    def pay(self):
        print("Logging: Starting payment operation.")
        self.real_payment.pay()
        print("Logging: Payment operation finished.")


# 使用代理
real_payment = RealPayment()
payment_proxy = PaymentProxy(real_payment)
payment_proxy.pay()

"""
Logging: Starting payment operation.
Paying...
Logging: Payment operation finished.
"""